package mine;


//import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
//import org.junit.runners.Parameterized;

import java.awt.*;
import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

//import static org.junit.jupiter.api.Assertions.assertEquals;
//@RunWith(Parameterized.class)//声明参数运行器
public class FishTest {
    Fish testFish=new Fish();
    Fish myFish= new Fish(true);

    @org.junit.Test
    public void rondowDirection() {
        //测试随机产生的方向
        int d=testFish.rondowDirection();
        assert(d==0||d==1);
    }

    @org.junit.Test
    public void rondowSpeed() {
        //测试随机产生的速度
        int s=testFish.rondowSpeed();
        assert(s>=4&&s<=8);
    }

    @org.junit.Test
    public void rondowGrade() {
        //测试随机产生4种鱼的分布
        int[] array=new int[100];
        int num1=0;
        int num2=0;
        int num3=0;
        int num4=0;
        for (int i=0;i<100;i++){
            array[i]=testFish.rondowGrade();
            switch (array[i]){
                case 1:
                    num1=num1+1;
                    break;
                case 2:
                    num2=num2+1;
                    break;
                case 3:
                    num3=num3+1;
                    break;
                case 4:
                    num4=num4+1;
                    break;
            }
        }
        assertEquals(100,num1+num2+num3+num4);
        System.out.println("随机产生的鱼无异常，只有四个等级");
        assert(num1>0);
        System.out.println("随机产生的一等鱼数量："+num1);
        assert(num2>0);
        System.out.println("随机产生的二等鱼数量："+num2);
        assert(num3>0);
        System.out.println("随机产生的三等鱼数量："+num3);
        assert(num4>0);
        System.out.println("随机产生的四等鱼数量："+num4);
    }

    @org.junit.Test
    public void rondowY() {
        //测试随机产生的鱼的初始Y坐标
        int Y=testFish.rondowY();
        assert(Y>=0&&Y<=799);
        System.out.println(Y);
    }
    //测试玩家鱼的移动
    @org.junit.Test
    public void move_1() {
        myFish.setX(1900);
        myFish.setY(980);
        myFish.setRight(true);
        myFish.setLeft(true);
        myFish.setDown(true);
        myFish.setUp(true);
        myFish.move();
        assertTrue(myFish.getX()==1891);
        assertTrue(myFish.getY()==971);
        Image expectImage=myFish.getImagePool().getImage(9);
        assertEquals(expectImage,myFish.getImage());
    }
    @org.junit.Test
    public void move_2() {
        myFish.setX(1813);
        myFish.setY(980);
        myFish.setRight(true);
        myFish.setLeft(true);
        myFish.setDown(true);
        myFish.setUp(true);
        myFish.move();
        assertTrue(myFish.getX()==1822);
        assertTrue(myFish.getY()==971);
        assertEquals(myFish.getImagePool().getImage(9),myFish.getImage());
    }
    @org.junit.Test
    public void move_3() {
        myFish.setX(1000);
        myFish.setY(1000);
        myFish.setRight(false);
        myFish.setLeft(false);
        myFish.setDown(true);
        myFish.setUp(true);
        myFish.move();
        assertTrue(myFish.getX()==1000);
        assertTrue(myFish.getY()==991);
        assertEquals(myFish.getImagePool().getImage(9),myFish.getImage());
    }
    @org.junit.Test
    public void move_4() {
        myFish.setX(2000);
        myFish.setY(917);
        myFish.setRight(true);
        myFish.setLeft(true);
        myFish.setDown(true);
        myFish.setUp(true);
        myFish.move();
        assertTrue(myFish.getX()==1991);
        assertTrue(myFish.getY()==926);
        assertEquals(myFish.getImagePool().getImage(9),myFish.getImage());
    }
    @org.junit.Test
    public void move_5() {
        myFish.setX(1910);
        myFish.setY(8);
        myFish.setRight(true);
        myFish.setLeft(true);
        myFish.setDown(false);
        myFish.setUp(true);
        myFish.move();
        assertTrue(myFish.getX()==1901);
        assertTrue(myFish.getY()==8);
        assertEquals(myFish.getImagePool().getImage(9),myFish.getImage());
    }
    @org.junit.Test
    public void move_6() {
        myFish.setX(1900);
        myFish.setY(980);
        myFish.setRight(true);
        myFish.setLeft(true);
        myFish.setDown(true);
        myFish.setUp(true);
        myFish.setDirection(1);
        myFish.setImage(myFish.getImagePool().getImage(9));
        myFish.move();
        assertTrue(myFish.getX()==1891);
        assertTrue(myFish.getY()==971);
        assertEquals(myFish.getImagePool().getImage(8),myFish.getImage());
    }
}
